<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        /*
        odd选中奇数项
        even偶数项
        */
        /* ul>li:nth-child(odd){
            color:red;
        }
        ul>li:nth-child(even){
            color:green;
        } */
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
    </ul>
    <script>
        var lis=document.getElementsByTagName("li");
        for(let i=0;i<lis.length;i++){
            if(i%2 == 0){
                lis[i].style.backgroundColor="pink";
            }else{
                lis[i].style.backgroundColor="#ADD8E6";
            }
        }
    </script>
</body>
</html>